package 如何初始化数组;

public class 数组反转21 {
	public static void main(String[] args) {
		int[] arr = new int[5];
		//赋值
		for(int i=0; i<arr.length-1; i++) {
			arr[i] = (int)(Math.random() * 100);
			System.out.println(arr[i]);
		}
		//翻转
		for(int i=0; i<arr.length-1; i++) {
			for(int j=0;j<arr.length-1-i; j++) {
				int k = arr[j];
				arr[j] = arr[j+1];
				arr[j+1] = k;
			}
		}
		//输出翻转数组
		for (int i : arr) {
			System.out.println(i);
		}
	}
}